package com.yanqu.road.webservice.invoke;

import com.sun.xml.internal.ws.client.BindingProviderProperties;
import com.yanqu.road.entity.player.UserInfo;
import com.yanqu.road.webservice.game.GameWebService;
import com.yanqu.road.webservice.game.GameWebServiceService;

import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import java.net.URL;
import java.util.Map;

public class GameWebServiceInvoke {

	private static GameWebService gameWebService;

	private static final String NAME_SPACE_URI = "http://webservice.server.road.yanqu.com/";

	private static final String LOCAL_PART = "GameWebServiceService";

	private GameWebServiceInvoke(URL url) {
		if (null == gameWebService) {
			gameWebService = new GameWebServiceService(url, new QName(NAME_SPACE_URI, LOCAL_PART)).getGameWebServicePort();
			Map<String, Object> dataMap = ((BindingProvider) gameWebService).getRequestContext();
			dataMap.put(BindingProviderProperties.REQUEST_TIMEOUT, 20 * 1000);
			dataMap.put(BindingProviderProperties.CONNECT_TIMEOUT, 20 * 1000);
		}
	}

	public static GameWebServiceInvoke getInstance(URL url) {
		return new GameWebServiceInvoke(url);
	}

	public static String executeAdminOperate(String op, String param) {
		return gameWebService.executeAdminOperate(op, param);
	}

	public static int executeAdminCommand(long userId, String commands) {
		return gameWebService.executeAdminCommand(userId, commands);
	}

	public static int notifyRechargeSuccess(String orderNo, int rechargeType) {
		return gameWebService.notifyRechargeSuccess(orderNo, rechargeType);
	}

	public static void recordUserIp(long userId, String ip) {
		gameWebService.recordUserIp(userId, ip);
	}

	public static void recordUserSign(long userId, String key, String value) {
		gameWebService.recordUserSign(userId, key, value);
	}

	public static void logPreRecharge(long userId, String orderNo, int mallId) {
		gameWebService.logPreRecharge(userId, orderNo, mallId);
	}

	public static String queryUser(String openId){
		return gameWebService.queryUser(openId);
	}

	public static String queryUserUnionInfo(String platformUserId, long userId){
		return gameWebService.queryUserUnionInfo(platformUserId, userId);
	}

	public static String queryUnionDetailInfo(String unionUid ){
		return gameWebService.queryUnionDetailInfo(unionUid);
	}

	public static String queryMallCanBuy(int activityId, int mallId, long userId, long couponItemId){
		return gameWebService.queryMallCanBuy(activityId, mallId, userId, couponItemId);
	}

	public static String getCanBuyProductList(long userId, String language, boolean isBackend){
		return gameWebService.getCanBuyProductList(userId, language, isBackend);
	}
	public static String getCanBuyProductListBackend(long userId, String language){
		return gameWebService.getCanBuyProductListBackend(userId, language);
	}

	public static int isProductCanBuy(long userId, int mallId){
		return gameWebService.isProductCanBuy(userId, mallId);
	}

	public static int platformSendReward(long userId, int goodsId, int count, int type){
		return gameWebService.platformSendReward(userId, goodsId, count, type);
	}

	public static String queryPlayerOnline(String openIds){
		return gameWebService.queryPlayerOnline(openIds);
	}

	public static boolean checkNameForbidden(String wordStr) {
		return gameWebService.checkNameForbidden(wordStr);
	}

	public static int changeUserNickName(long userId) {
		return gameWebService.changeUserNickName(userId);
	}

	public static int changeUnion(String unionId, String type) {
		return gameWebService.changeUnion(unionId, type);
	}

	public static void roleReport(String platformUserId, String userId, String nickName, String ip) {
		gameWebService.roleReport(platformUserId, userId, nickName, ip);
	}

	public static void updateUserPlatformUserId(long userId, String platformUserId, String platformUserName) {
		gameWebService.updateUserPlatformUserId(userId, platformUserId, platformUserName);
	}

	public static String queryUserByAliasId(long userAliasId){
		return gameWebService.queryUserByAliasId(userAliasId);
	}

	public static String queryUserUpgradeTime(long userId, int titleId){
		return gameWebService.queryUserUpgradeTime(userId, titleId);
	}

	public static String queryXiaoMianData(String param){
		return gameWebService.queryXiaoMianData(param);
	}

	public static int queryRechargeSwitchOpen(long userId) {
		return gameWebService.queryRechargeSwitchOpen(userId);
	}

	public static String queryDailyTaskProgress(String param){
		return gameWebService.queryDailyTaskProgress(param);
	}

	public static int notifyDeductIngots(String orderNo){
		return gameWebService.notifyDeductIngots(orderNo);
	}

	public static int loginCheckGameServerMemory(long userId) {
		return gameWebService.loginCheckGameServerMemory(userId);
	}

	public static void triggerPlatformUserBehavior(int type, String platformUserId, String date) {
		gameWebService.triggerPlatformUserBehavior(type, platformUserId, date);
	}

	public static void addUserBehavior(String uid, int type){
		gameWebService.addUserBehavior(uid, type);
	}

	public static int reachPlatformCondition(long userId, int type){
		return gameWebService.reachPlatformCondition(userId, type);
	}

	public static String listCommandApi(){
		return gameWebService.listCommandApi();
	}

	public static long queryServerOnline() {
		return gameWebService.queryServerOnline();
	}

	public static String reduceToken(String orderNo) {
		return gameWebService.reduceToken(orderNo);
	}
}
